package com.dq.controller;

import com.dq.mapper.AuthMapper;
import com.dq.pojo.Authentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/auth")
public class AuthController {
    @Autowired
    AuthMapper authMapper;

    @RequestMapping("/")
    public String getAllAuths(Model model){
        List<Authentication> auths = authMapper.getAllAuths();
        model.addAttribute("auths",auths);
        return "/admin/index";
    }

    @RequestMapping("/toInsert")
    public String toInsertAuth(){
        return "/admin/auth/insertAuth";
    }
    @RequestMapping("/insert")
    public String insertAuth(Authentication auth){
        authMapper.insertAuth(auth);
        return "redirect:/auth/";
    }

}
